deploy: Avoid trying to change immutable state unnecessarily
authorColin Walters <walters@verbum.org>
Fri, 14 Feb 2020 16:35:50 +0000 (16:35 +0000)
committerColin Walters <walters@verbum.org>
Fri, 14 Feb 2020 16:37:38 +0000 (16:37 +0000)
For some reason I haven't fully debugged (probably a recent
kernel change), in the case where the immutable bit isn't set,
trying to call `EXT2_IOC_SETFLAGS` without it set returns `EINVAL`.

Let's avoid calling the `ioctl()` if we don't have anything to do.

This fixes a slew of `make check` failures here in my toolbox
environment.

(kernel is `5.5.0-0.rc6.git0.1.fc32.x86_64` with `xfs`)

src/libostree/ostree-linuxfsutil.c

index d1dde8b4b43eeda7933707d7d9f1009724351dbb..231ecf76a8075dcfff4a9bbe956f61fc227f0718 100644 (file)
@@ -68,6 +68,10 @@ _ostree_linuxfs_fd_alter_immutable_flag (int            fd,
     }
   else
     {
+      gboolean prev_immutable_state = (flags & EXT2_IMMUTABLE_FL) > 0;
+      if (prev_immutable_state == new_immutable_state)
+        return TRUE;  /* Nothing to do */
+
       if (new_immutable_state)
         flags |= EXT2_IMMUTABLE_FL;
       else